﻿if(localStorage.refresh == "true" /*&& parseInt($("#RemainS span.form_game:eq(0)").text()) <= 15*/) {
	localStorage.refresh = "false";
	console.log("wait to refresh...");
	setTimeout(function() {
		window.location.reload();
	}, (parseInt($("#RemainS span.form_game:eq(0)").text())+15)*1000);
}
else if( parseInt($("#RemainS span.form_game:eq(0)").text()) <= 10 || !(parseInt($("#RemainS span.form_game:eq(0)").text()) > 0) ) {
	setTimeout(function() {
		window.location.reload();
	}, 15000);
}
else {
	console.log("剩余时间：" + $("#RemainS span.form_game:eq(0)").text() + "s");
	var history = [];
	for(var i = 0; i < 10; i++) {
		history.push($("#panel tr:eq(" + (6+i) + ") img:eq(0)").attr("src").match(/[1-9]+/));
	}
	var loseCount = 0;
	var distMask = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1];
	for (var i = 0; i < 10; i++) {
		if (distMask[history[i]] > 0) {
			break;
		} else {
			loseCount++;
		}
	}
	console.log(loseCount);
	localStorage.loseCount = loseCount;
	setTimeout(function() {
		window.location = $("#panel tr:eq(5) a").attr("href");
	}, 5000);
}